export default {
	name: "query-notices",
	data() {
		return {
			firstParams: [
				{label: "编号", kind: "input", prop: "id", isEdit: false, disabled: false},
				{label: "标题", kind: "input", prop: "title", isEdit: false, disabled: false},
				{
					label: "紧急程度", kind: "select", prop: "level", isEdit: false, disabled: false,
					selectOptions: [
						{label: "普通", value: "1"},
						{label: "重要", value: "2"},
						{label: "紧急", value: "3"},
						{label: "严重", value: "4"}
					]
				},
				{label: "发布时间", kind: "date", prop: "startDate", isEdit: false, disabled: false},
				{label: "截止时间", kind: "date", prop: "endDate", isEdit: false, disabled: false}
			],
			secondParams: [],
			columns: [
				{label: "编号", prop: "id", kind: "input", width: 120, sortable: true, isSum: false},
				{label: "标题", prop: "title", kind: "input", width: 160, sortable: false, isSum: false},
				{label: "发布日期", prop: "startDate", kind: "datetime", width: 220, sortable: true, isSum: false},
				{label: "截止日期", prop: "endDate", kind: "datetime", width: 220, sortable: true, isSum: false},
				{label: "紧急程度", prop: "level", kind: "input", width: 150, sortable: true, isSum: false},
				{label: "内容", prop: "content", kind: "input", sortable: false, isSum: false}
			],
			contrast: {
				"普通": "1",
				"重要": "2",
				"紧急": "3",
				"严重": "4"
			},
			stripe: false,
			isMultiple: false,
			isSum: false,
			data: []
		};
	},
	created() {
		this.addData();
	},
	methods: {
		addData() {
			for (let i = 0; i < 100; i++) {
				let title = this.randomUtils.randomString();
				let level = i % 2 === 0 ? "普通" : (i % 3 === 0 ? "重要" : (i % 5 === 0 ? "紧急" : "严重"));
				let startDate = this.randomUtils.randomDate();
				let endDate = this.randomUtils.randomDate();
				let event = {
					id: this.randomUtils.randomNumber(1, 200),
					title: title,
					level: level,
					startDate: startDate,
					endDate: endDate,
					content: "标题 ： " + title + "，起始日期 ：" + this.dateUtils.toLocalString(startDate) + "，截止日期 ： " + this.dateUtils.toLocalString(endDate)
				};
				this.data.push(event);
			}
		},
		searchData() {
			return this.$refs.searchPage.filterData(this.data);
		},
		navigateTo(row) {
			this.$router.push({
				name: "add-notice",
				params: {
					data: row,
					action: "update"
				}
			});
		}
	}
};
